<template>
  <div class="dispatchQueryContent">
    <div class="dispatchQueryTitle">
      <!-- <div class="customerTitle">海川医药调度{{ systemTime }}日报</div> -->
      <div class="customerTitle">海川医药调度{{ dateTransfer }}日报</div>
      <!-- <div class="searchBtn">
        <el-date-picker
          v-model="dateRange"
          style="width: 240px"
          value-format="yyyy-MM-dd"
          type="daterange"
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        ></el-date-picker>
        <el-button type="success" @click="handlesearch">搜索</el-button>
      </div> -->
    </div>
    <div class="dispatchQuerytable">
      <div class="customtr1">
        <div class="customText">客户</div>
        <div class="delivery">
          <div class="deliveryTop">出库</div>
          <div class="deliveryBottom">
            <span>类型</span>
            <span>零货条目数</span>
            <span>补货箱数</span>
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">接收</div>
          <div class="deliveryBottom">
            <span>订单数</span>
            <span>条目数</span>
            <span>金额(万)</span>
          </div>
        </div>
        <div class="ReceiveNoSent">
          <div class="deliveryTop">接收未下发</div>
          <div class="deliveryBottom">
            <span>合计</span>
            <span>节点前</span>
          </div>
        </div>
        <div class="completeText">完成时间点</div>
      </div>
      <div class="customtr2">
        <div class="customText wyLayout">陕西海通</div>
        <div class="delivery">
          <div class="deliveryTop wyLayout">2B</div>
          <div class="deliveryBottom wyLayout">2C</div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculateTotal"
              v-model="form.htOutBLhtms"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculateTotal"
              v-model="form.htOutCLhtms"
              size="medium"
            />
          </div>
        </div>
        <div class="customText bhxsbg">
          <el-input
            disabled
            @input="calculatebhxsTotal"
            v-model="form.htOutBhxs"
            size="medium"
          />
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              v-model="form.htReceiveBDds"
              @input="calculateddsTotal"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              v-model="form.htReceiveCDds"
              @input="calculateddsTotal"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatetmsTotal"
              v-model="form.htReceiveBTms"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatetmsTotal"
              v-model="form.htReceiveCTms"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatejeTotal"
              v-model="form.htReceiveBJe"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatejeTotal"
              v-model="form.htReceiveCJe"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatehjTotal"
              v-model="form.htNotBHj"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatehjTotal"
              v-model="form.htNotCHj"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatejdqTotal"
              v-model="form.htNotBJdq"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatejdqTotal"
              v-model="form.htNotCJdq"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop noborder">
            <el-input disabled v-model="form.htTimeBWcsj" size="medium" />
            <!-- <el-time-picker
                v-model="form.htTimeBWcsj"
                placeholder=""
                value-format="HH:mm"
              >
              </el-time-picker> -->
          </div>
          <div class="deliveryBottom noborder">
            <el-input disabled v-model="form.htTimeCWcsj" size="medium" />
            <!-- <el-time-picker
                v-model="form.htTimeCWcsj"
                placeholder=""
                value-format="HH:mm"
              >
              </el-time-picker> -->
          </div>
        </div>
      </div>
      <div class="customtr2">
        <div class="customText wyLayout">陕西伟业</div>
        <div class="delivery">
          <div class="deliveryTop wyLayout">2B</div>
          <div class="deliveryBottom wyLayout">2C</div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculateTotal"
              v-model="form.wyOutBLhtms"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculateTotal"
              v-model="form.wyOutCLhtms"
              size="medium"
            />
          </div>
        </div>
        <div class="customText bhxsbg">
          <el-input
            disabled
            @input="calculatebhxsTotal"
            v-model="form.wyOutBhxs"
            size="medium"
          />
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              v-model="form.wyReceiveBDds"
              @input="calculateddsTotal"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              v-model="form.wyReceiveCDds"
              @input="calculateddsTotal"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatetmsTotal"
              v-model="form.wyReceiveBTms"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatetmsTotal"
              v-model="form.wyReceiveCTms"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatejeTotal"
              v-model="form.wyReceiveBJe"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatejeTotal"
              v-model="form.wyReceiveCJe"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatehjTotal"
              v-model="form.wyNotBHj"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatehjTotal"
              v-model="form.wyNotCHj"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop">
            <el-input
              disabled
              @input="calculatejdqTotal"
              v-model="form.wyNotBJdq"
              size="medium"
            />
          </div>
          <div class="deliveryBottom">
            <el-input
              disabled
              @input="calculatejdqTotal"
              v-model="form.wyNotCJdq"
              size="medium"
            />
          </div>
        </div>
        <div class="delivery">
          <div class="deliveryTop noborder">
            <el-input disabled v-model="form.wyTimeBWcsj" size="medium" />
            <!-- <el-time-picker
                v-model="form.wyTimeBWcsj"
                placeholder=""
                value-format="HH:mm"
              >
              </el-time-picker> -->
          </div>
          <div class="deliveryBottom noborder">
            <el-input disabled v-model="form.wyTimeCWcsj" size="medium" />
            <!-- <el-time-picker
                v-model="form.wyTimeCWcsj"
                placeholder=""
                value-format="HH:mm"
              >
              </el-time-picker> -->
          </div>
        </div>
      </div>
      <div class="customtr3">
        <div class="customText wyLayout">其他货主</div>
        <div class="customText wyLayout">/</div>
        <div class="customText">
          <el-input
            disabled
            @input="calculateTotal"
            v-model="form.qtOutLhtms"
            size="medium"
          />
        </div>
        <div class="customText">
          <el-input
            disabled
            @input="calculatebhxsTotal"
            v-model="form.qtOutBhxs"
            size="medium"
          />
        </div>
        <div class="customText">
          <el-input
            disabled
            v-model="form.qtReceiveBDds"
            @input="calculateddsTotal"
            size="medium"
          />
        </div>
        <div class="customText">
          <el-input
            disabled
            @input="calculatetmsTotal"
            v-model="form.qtReceiveBTms"
            size="medium"
          />
        </div>
        <div class="customText">
          <el-input
            disabled
            @input="calculatejeTotal"
            v-model="form.qtReceiveBJe"
            size="medium"
          />
        </div>
        <div class="customText">
          <el-input
            disabled
            @input="calculatehjTotal"
            v-model="form.qtNotBHj"
            size="medium"
          />
        </div>
        <div class="customText">
          <el-input
            disabled
            @input="calculatejdqTotal"
            v-model="form.qtNotBJdq"
            size="medium"
          />
        </div>
        <div class="completeText">
          <el-input disabled v-model="form.qtTimeCWcsj" size="medium" />
          <!-- <el-time-picker
              v-model="form.qtTimeCWcsj"
              placeholder=""
              value-format="HH:mm"
            >
            </el-time-picker> -->
        </div>
      </div>
      <div class="customtr4">
        <div class="customText wyLayout totalText">合计</div>
        <!-- <div class="customText"></div> -->
        <div class="customText">
          <el-input disabled v-model="lhtmsTotal" size="medium" />
        </div>
        <div class="customText">
          <el-input disabled v-model="bhxsTotal" size="medium" />
        </div>
        <div class="customText">
          <el-input disabled v-model="ddsTotal" size="medium" />
        </div>
        <div class="customText">
          <el-input disabled v-model="tmsTotal" size="medium" />
        </div>
        <div class="customText">
          <el-input disabled v-model="jeTotal" size="medium" />
        </div>
        <div class="customText">
          <el-input disabled v-model="hjTotal" size="medium" />
        </div>
        <div class="customText">
          <el-input disabled v-model="jdqTotal" size="medium" />
        </div>
        <div class="completeText bhxsbg"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { dailyaddlist, dailyParamslist } from "@/api/subSystem/continer";
export default {
  props: {
    dateTransfer: {
      type: String,
    },
  },
  data() {
    return {
      lhtmsTotal: undefined,
      bhxsTotal: undefined,
      ddsTotal: undefined,
      tmsTotal: undefined,
      jeTotal: undefined,
      hjTotal: undefined,
      jdqTotal: undefined,
      // 伟业
      form: {
        addTime: new Date().toISOString().split("T")[0],
        wyOutBLhtms: null,
        wyOutCLhtms: null,
        wyOutBhxs: null,
        wyReceiveBDds: null,
        wyReceiveCDds: null,
        wyReceiveBTms: null,
        wyReceiveCTms: null,
        wyReceiveBJe: null,
        wyReceiveCJe: null,
        wyNotBHj: null,
        wyNotCHj: null,
        wyNotBJdq: null,
        wyNotCJdq: null,
        wyTimeBWcsj: null,
        wyTimeCWcsj: null,
        htOutBLhtms: null,
        htOutCLhtms: null,
        htOutBhxs: null,
        htReceiveBDds: null,
        htReceiveCDds: null,
        htReceiveBTms: null,
        htReceiveCTms: null,
        htReceiveBJe: null,
        htReceiveCJe: null,
        htNotBHj: null,
        htNotCHj: null,
        htNotBJdq: null,
        htNotCJdq: null,
        htTimeBWcsj: null,
        htTimeCWcsj: null,
        qtOutLhtms: null,
        qtOutBhxs: null,
        qtReceiveBDds: null,
        qtReceiveBTms: null,
        qtReceiveBJe: null,
        qtNotBHj: null,
        qtNotBJdq: null,
        qtTimeCWcsj: null,
      },
      // 日期范围
      dateRange: [
        new Date().toISOString().split("T")[0],
        new Date().toISOString().split("T")[0],
      ],
      systemTime: "",
      templateValue: "调度日报",
      options: [
        {
          value: "1",
          label: "调度日报",
        },
      ],
      queryParams: {},
    };
  },
  mounted() {
    // 创建一个 Date 对象
    const currentDate = new Date();
    // 获取当前年份
    const year = currentDate.getFullYear();
    // 获取当前月份（注意：月份是从 0 开始计数的，所以需要加 1）
    const month = currentDate.getMonth() + 1;
    // 获取当前日期
    const day = currentDate.getDate();
    // 打印年月日
    this.systemTime = `${year}年${month}月${day}日`;
    // this.getTodayList();
  },
  beforeDestroy() {},
  methods: {
    handlesearch() {
      this.getTodayList();
    },
    getTodayList() {
      dailyParamslist({addTime:this.dateTransfer}).then(
        (res) => {
          if (res.data) {
            this.form = res.data;
            this.jdqTotal =
              Number(this.form.wyNotBJdq) +
              Number(this.form.wyNotCJdq) +
              Number(this.form.htNotBJdq) +
              Number(this.form.htNotCJdq) +
              Number(this.form.qtNotBJdq);
            this.hjTotal =
              Number(this.form.wyNotBHj) +
              Number(this.form.wyNotCHj) +
              Number(this.form.htNotBHj) +
              Number(this.form.htNotCHj) +
              Number(this.form.qtNotBHj);
            this.jeTotal = this.addDecimals(
              Number(this.form.wyReceiveBJe),
              Number(this.form.wyReceiveCJe),
              Number(this.form.htReceiveBJe),
              Number(this.form.htReceiveCJe),
              Number(this.form.qtReceiveBJe)
            );
            this.tmsTotal =
              Number(this.form.wyReceiveBTms) +
              Number(this.form.wyReceiveCTms) +
              Number(this.form.htReceiveBTms) +
              Number(this.form.htReceiveCTms) +
              Number(this.form.qtReceiveBTms);
            this.ddsTotal =
              Number(this.form.wyReceiveBDds) +
              Number(this.form.wyReceiveCDds) +
              Number(this.form.htReceiveBDds) +
              Number(this.form.htReceiveCDds) +
              Number(this.form.qtReceiveBDds);
            this.bhxsTotal =
              Number(this.form.wyOutBhxs) +
              Number(this.form.htOutBhxs) +
              Number(this.form.qtOutBhxs);
            this.lhtmsTotal =
              Number(this.form.wyOutBLhtms) +
              Number(this.form.wyOutCLhtms) +
              Number(this.form.htOutBLhtms) +
              Number(this.form.htOutCLhtms) +
              Number(this.form.qtOutLhtms);
          } else {
            this.form = {};
            this.lhtmsTotal = null;
            this.bhxsTotal = null;
            this.ddsTotal = null;
            this.tmsTotal = null;
            this.jeTotal = null;
            this.hjTotal = null;
            this.jdqTotal = null;
          }
        }
      );
    },
    // 零货条目数总和
    // calculateTotal() {
    //   this.lhtmsTotal =
    //     parseInt(this.form.wyOutBLhtms, 10) +
    //     parseInt(this.form.wyOutCLhtms, 10) +
    //     parseInt(this.form.htOutBLhtms, 10) +
    //     parseInt(this.form.htOutCLhtms, 10) +
    //     parseInt(this.form.qtOutLhtms, 10);
    // },
    addDecimals(...nums) {
      const precision = 1000000; // 保留六位小数
      const sum = nums.reduce(
        (acc, num) => acc + Math.round(num * precision),
        0
      );
      return sum / precision;
    },
    calculatejdqTotal() {
      this.jdqTotal =
        Number(this.form.wyNotBJdq) +
        Number(this.form.wyNotCJdq) +
        Number(this.form.htNotBJdq) +
        Number(this.form.htNotCJdq) +
        Number(this.form.qtNotBJdq);
    },
    calculatehjTotal() {
      this.hjTotal =
        Number(this.form.wyNotBHj) +
        Number(this.form.wyNotCHj) +
        Number(this.form.htNotBHj) +
        Number(this.form.htNotCHj) +
        Number(this.form.qtNotBHj);
    },
    calculatejeTotal() {
      this.jeTotal = this.addDecimals(
        Number(this.form.wyReceiveBJe),
        Number(this.form.wyReceiveCJe),
        Number(this.form.htReceiveBJe),
        Number(this.form.htReceiveCJe),
        Number(this.form.qtReceiveBJe)
      );
    },
    calculatetmsTotal() {
      this.tmsTotal =
        Number(this.form.wyReceiveBTms) +
        Number(this.form.wyReceiveCTms) +
        Number(this.form.htReceiveBTms) +
        Number(this.form.htReceiveCTms) +
        Number(this.form.qtReceiveBTms);
    },
    calculateddsTotal() {
      this.ddsTotal =
        Number(this.form.wyReceiveBDds) +
        Number(this.form.wyReceiveCDds) +
        Number(this.form.htReceiveBDds) +
        Number(this.form.htReceiveCDds) +
        Number(this.form.qtReceiveBDds);
    },
    calculatebhxsTotal() {
      this.bhxsTotal =
        Number(this.form.wyOutBhxs) +
        Number(this.form.htOutBhxs) +
        Number(this.form.qtOutBhxs);
    },
    calculateTotal() {
      this.lhtmsTotal =
        Number(this.form.wyOutBLhtms) +
        Number(this.form.wyOutCLhtms) +
        Number(this.form.htOutBLhtms) +
        Number(this.form.htOutCLhtms) +
        Number(this.form.qtOutLhtms);
    },
    goBack() {
      this.$router.push("/subSystem1");
    },
  },
};
</script>

<style lang="scss" scoped>
.dispatchQueryContent {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  .dispatchQueryTitle {
    text-align: center;
    // height: 120px;
    .customerTitle {
      font-size: 30px;
      font-weight: 700;
      // margin-bottom: 10px;
      margin: 10px 0 20px 0;
    }
    .searchBtn {
      ::v-deep .el-button--success {
        margin-left: 30px;
      }
    }
  }
  .dispatchQuerytable {
    width: 80%;
    // margin-top: 20px;
    ::v-deep .el-input--medium .el-input__inner {
      height: 65px;
      line-height: 65px;
      border: none;
      text-align: center;
      font-size: 16px;
      color: #000000;
    }
    ::v-deep .el-date-editor.el-input,
    .el-date-editor.el-input__inner {
      width: 100%;
    }

    .customtr1 {
      width: 100%;
      height: 140px;
      border: 1px solid #e7dfdf;
      background: #05a5ff;
      display: flex;
      font-size: 16px;
      font-weight: 700;
      color: #ffffff;
      justify-content: space-around;
      .customText {
        width: 10%;
        height: 140px;
        line-height: 140px;
        text-align: center;
        border-right: 1px solid #e7dfdf;
      }

      .completeText {
        width: 10%;
        height: 140px;
        line-height: 140px;
        text-align: center;
      }
      .delivery {
        width: 30%;
        display: flex;
        flex-direction: column;
        .deliveryTop {
          height: 50%;
          line-height: 70px;
          border-right: 1px solid #e7dfdf;
        }
        .deliveryBottom {
          height: 50%;
          display: flex;
          justify-content: space-around;
          border-top: 1px solid #e7dfdf;
          span {
            width: 34%;
            height: 100%;
            line-height: 70px;
            text-align: center;
            border-right: 1px solid #e7dfdf;
          }
        }
      }
      .ReceiveNoSent {
        width: 20%;
        .deliveryTop {
          height: 50%;
          line-height: 70px;
          border-right: 1px solid #e7dfdf;
        }
        .deliveryBottom {
          height: 50%;
          display: flex;
          justify-content: space-around;
          border-top: 1px solid #e7dfdf;
          span {
            width: 50%;
            height: 100%;
            line-height: 70px;
            text-align: center;
            border-right: 1px solid #e7dfdf;
          }
        }
      }
    }
    .customtr2 {
      width: 100%;
      height: 140px;
      border-bottom: 1px solid #181616;
      border-left: 1px solid #181616;
      border-right: 1px solid #181616;
      // background: #00d9ff;
      display: flex;
      justify-content: space-around;
      .customText {
        width: 10%;
        height: 140px;
        line-height: 140px;
        text-align: center;
        border-right: 1px solid #181616;
      }
      .bhxsbg {
        background: #f5f7fa;
        border-bottom: 1px solid #181616;
      }
      .wyLayout {
        font-weight: 700;
      }
      .delivery {
        width: 10%;
        display: flex;
        flex-direction: column;
        //   border-right: 1px solid #181616;
        .deliveryTop {
          height: 50%;
          line-height: 70px;
          border-right: 1px solid #181616;
        }
        .noborder {
          border-right: none !important;
        }
        .deliveryBottom {
          height: 50%;
          display: flex;
          line-height: 70px;
          justify-content: space-around;
          border-top: 1px solid #181616;
          border-right: 1px solid #181616;
        }
      }
    }
    .customtr3 {
      width: 100%;
      height: 70px;
      border-bottom: 1px solid #181616;
      border-left: 1px solid #181616;
      border-right: 1px solid #181616;
      // background: #00d9ff;
      display: flex;
      justify-content: space-around;
      .customText {
        width: 10%;
        height: 70px;
        line-height: 70px;
        text-align: center;
        border-right: 1px solid #181616;
      }
      .totalText {
        width: 20%;
      }
      .bhxsbg {
        background: #f5f7fa;
        border-bottom: 1px solid #181616;
      }
      .wyLayout {
        font-weight: 700;
      }
      .completeText {
        width: 10%;
        height: 70px;
        line-height: 70px;
        text-align: center;
      }
    }
    .customtr4 {
      width: 100%;
      height: 70px;
      border-bottom: 1px solid #181616;
      border-left: 1px solid #181616;
      border-right: 1px solid #181616;
      background: #75d561;
      display: flex;
      justify-content: space-around;
      ::v-deep .el-input.is-disabled .el-input__inner {
        background: #75d561;
        font-weight: 700;
        color: #ff4800;
        font-size: 18px;
      }
      .customText {
        width: 10%;
        height: 70px;
        line-height: 70px;
        text-align: center;
        border-right: 1px solid #181616;
      }
      .totalText {
        width: 20%;
      }
      .bhxsbg {
        background: #f5f7fa;
        border-bottom: 1px solid #181616;
      }
      .wyLayout {
        font-weight: 700;
      }
      .completeText {
        background: #75d561;
        width: 10%;
        height: 70px;
        line-height: 70px;
        text-align: center;
      }
    }
  }
}
</style>